package com.taoyi.mhouse.base.impl;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.taoyi.mhouse.R;
import com.taoyi.mhouse.adapter.RecommendHomeAdapter;
import com.taoyi.mhouse.base.BasePager;
import com.taoyi.mhouse.binder.BannerBinder;
import com.taoyi.mhouse.binder.BroadcastingBinder;
import com.taoyi.mhouse.binder.GoodsBinder;
import com.taoyi.mhouse.binder.HeadLineBinder;
import com.taoyi.mhouse.util.UIUtils;

/**
 * Created by tempo on 2015/11/12.
 */
public class RecommendPagerHome extends BasePager {
    private RecyclerView rvHome;
    RecyclerView.LayoutManager layoutManager;
    private RecommendHomeAdapter mAdapter;

    @Override
    public View getView() {
        rvHome = (RecyclerView) View.inflate(UIUtils.getContext(), R.layout.fragment_recommend, null);
        rvHome.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(UIUtils.getContext());
        rvHome.setLayoutManager(layoutManager);
        init();
        return rvHome;
    }

    public void init() {
        mAdapter = new RecommendHomeAdapter();
        mAdapter.putBinder(RecommendHomeAdapter.ViewType.BROADCASTING,new BroadcastingBinder(mAdapter));
        mAdapter.putBinder(RecommendHomeAdapter.ViewType.HEADLINES,new HeadLineBinder(mAdapter));
        mAdapter.putBinder(RecommendHomeAdapter.ViewType.BANNER, new BannerBinder(mAdapter));
        mAdapter.putBinder(RecommendHomeAdapter.ViewType.GOODS,new GoodsBinder(mAdapter));
        rvHome.setAdapter(mAdapter);
    }

}
